// 控件视图
export default function useWidgetView() {
    // 获取控件视图dom(包裹控件的外层dom)
    const getWidgetViewDom = id => {
        if (Object.prototype.toString.call(id) === '[object Array]') {
            return id.map(itemId => document.getElementById(`widget-view-${itemId}`))
        } else {
            return document.getElementById(`widget-view-${id}`)
        }
    }

    // 获取控件dom
    const getWidgetDom = id => {
        if (Object.prototype.toString.call(id) === '[object Array]') {
            return id.map(itemId => document.getElementById(itemId))
        } else {
            return document.getElementById(id)
        }
    }

    return {
        getWidgetViewDom,
        getWidgetDom
    }
}